﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BiliBiliCSharpStudy.old {
    class NullableDemo {
        public static void demo() {
            //test1();
            //test2();
            test3();
        }

        public static void test3() {
            int? x = null;
            int y = x ?? 1;
            Console.WriteLine(x);
            Console.WriteLine(y);
        }

        public static void test2() {
            int? x = null;
            Console.WriteLine(x);
            x = 100;
            Console.WriteLine(x);
            Console.WriteLine(x.Value);
        }

        public static void test1() {
            Nullable<int> x = null;
            Console.WriteLine(x.HasValue);
            x = 100;
            Console.WriteLine(x.HasValue);
            Console.WriteLine("x: " + x);
        }
    }
}
